//
//  IManager+FoodRecommend.m
//  RocketProject
//
//  Created by chen jiedan on 13-6-25.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+FoodRecommend.h"
#import "NetUrlDefines.h"
#import "RequestUtlity.h"
#import "FrameworkRelativeDefines.h"
#import "RCRecommendFoodDataModel.h"
#import "RCMerchantsListDataModel.h"
#import "GloableEngineService.h"

@implementation IManager (FoodRecommend)

- (int64_t) requestRecommendFoodForPage:(NSString *)page withDelegate:(id<IManagerDelegate>)delegate
{
    if (nil == page) {
        return kInvalidRequestId;
    }
    // 异步获取数据
    NSString *cityID = [[GloableEngineService sharedInstance] selectedCityID];
    CLLocationCoordinate2D coor = [[GloableEngineService sharedInstance] userLocation];

    NSString *urlSuffix = [NSString stringWithFormat:kRCRecommendFoodPrefix,cityID,[page intValue],10,coor.latitude,coor.longitude];
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
//    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"RecommendFoodList"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCRecommendFoodListDataModel class]
                                                     withDataDelegate:delegate];
}


-(int64_t)requestRecommendRestaurantForFood:(NSString *)foodName forPage:(NSString *)page withDelegate:(id<IManagerDelegate>)delegate
{
    if (nil == page) {
        return kInvalidRequestId;
    }
    // 异步获取数据
    // 异步获取数据
    NSString *cityID = [[GloableEngineService sharedInstance] selectedCityID];
    CLLocationCoordinate2D coor = [[GloableEngineService sharedInstance] userLocation];
    
    NSString *urlSuffix = [NSString stringWithFormat:kRCRecommendResUrlPrefix,cityID,foodName,[page intValue],10,coor.latitude,coor.longitude];

//    NSString *urlSuffix = [NSString stringWithFormat:kRCRecommendResUrlPrefix,foodID,[page intValue],10];
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
//    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"RecommendRestaurantList"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCRecommendRestaurantListDataModel class]
                                                     withDataDelegate:delegate];
}


@end
